import { fetch } from './fetch.js'
/***************核销****************** */
//登录
export function login (userName,password) {
  return fetch({
    url: '/wechat/registrationWriter/login',
    method: 'get',
    params: {
      userName,
      password
    }
  })
}
//扫一扫或者分享
export function wxconfig (url) {
  return fetch({
    url: '/wechat/registration/share',
    method: 'post',
    data: {
      url
    }
  })
}
//根据code查报名人信息
export function codeInfo (code) {
  return fetch({
    url: '/wechat/registrationWriter/queryRecordInfo',
    method: 'get',
    params: {
      code
    }
  })
}
//核销
export function writeoff (code,writerId) {
  return fetch({
    url: '/wechat/registrationWriter/write',
    method: 'get',
    params: {
      code,
      writerId
    }
  })
}
//核销记录
export function getWriteList (id,pageNo) {
  return fetch({
    url: '/wechat/registrationWriter/queryWriteList',
    method: 'get',
    params: {
      id,
      pageNo
    }
  })
}
//核销记录数量
export function getWriteListNum (writeId) {
  return fetch({
    url: '/wechat/registrationWriter/selectWriteNum',
    method: 'get',
    params: {
      writeId
    }
  })
}
/************微信登录*************** */
//获得微信token
export function getWxToken (code) {
  return fetch({
    url: '/wechat/user/security/wx_token',
    method: 'get',
    params: {
      code
    }
  })
}
//获得微信用户信息
export function getWxUserinfo (access_token,openid) {
  return fetch({
    url: '/wechat/user/security/userinfo',
    method: 'get',
    params: {
      access_token,
      openid
    }
  })
}
//创建用户
export function checkOpenIdNew (openId,avatar,nickName) {
  return fetch({
    url: '/wechat/user/security/checkOpenIdNew',
    method: 'get',
    params: {
      openId,
      avatar,
      nickName
    }
  })
}

/* ----首页----- */
//首页活动列表数据（get）
export function getActivityData (pageNo) {
  return fetch({
    url: '/wechat/registration/list',
    method: 'get',
    params: {
      pageNo
    }
  })
}
//列表详情数据
export function getActivityDetailData (id) {
  return fetch({
    url: '/wechat/registration/info',
    method: 'get',
    params: {
      id
    }
  })
}
//分享海报
export function getposters (userId,url) {
  return fetch({
    url: '/wechat/registration/posters',
    method: 'get',
    params: {
      userId,
      url
    }
  })
}
//列表详情_报名人数数据
export function registrationRecordList (registrationId,pageNo) {
  return fetch({
    url: '/wechat/registrationRecord/list',
    method: 'get',
    params: {
      registrationId,
      pageNo
    }
  })
}
//列表详情_报名人数数据
export function recordInfo (id) {
  return fetch({
    url: '/wechat/registrationRecord/recordInfo',
    method: 'get',
    params: {
      id
    }
  })
}
//列表详情_报名人数量
export function selectNumByUserId (registrationId) {
  return fetch({
    url: '/wechat/registrationRecord/selectNumByUserId',
    method: 'get',
    params: {
      registrationId
    }
  })
}
//报名页面-是否提交过订单
export function recordInfos (userId,registrationId) {
  return fetch({
    url: '/wechat/registrationRecord/recordInfo',
    method: 'get',
    params: {
      userId,
      registrationId
    }
  })
}
//报名页面-回显内容
export function recordInfos2 (orderId) {
  return fetch({
    url: '/wechat/registrationRecord/recordInfo',
    method: 'get',
    params: {
      orderId
    }
  })
}
//列表详情_当前用户数据
export function getCurrentUser (userId,registrationId) {
  return fetch({
    url: '/wechat/registration/userDisplayInfo',
    method: 'get',
    params: {
      userId,
      registrationId
    }
  })
}
//发起人数据
export function originatorInfo (userId) {
  return fetch({
    url: '/wechat/user/info',
    method: 'get',
    params: {
      userId
    }
  })
}
//收藏或者取消收藏
export function saveCollect (userId,registrationId) {
  return fetch({
    url: '/wechat/registrationCollect/save',
    method: 'get',
    params: {
      userId,
      registrationId
    }
  })
}
//报名数据
export function registrationSave (user) {
  user = JSON.stringify(user)
  return fetch({
    url: '/wechat/registrationRecord/save',
    method: 'post',
    data:{
      user
    }
  })
}
//订单支付
export function unifiedOrder (openid,orderId,userId) {
  return fetch({
    url: '/wechat/registrationOrderPay/unifiedOrder',
    method: 'post',
    data: {
      openid,
      orderId,
      userId
    }
  })
}
//微信支付回调
export function paymentBack () {
  return fetch({
    url: '/wechat/registrationOrderPay/pay_notify',
    method: 'post',
    data: {
    }
  })
}
/**************我的******************* */
//收藏数量
export function getCollectNum (userId) {
  return fetch({
    url: '/wechat/registrationCollect/selectRegistrationCollectNum',
    method: 'get',
    params: {
      userId
    }
  })
}
//参与活动数量
export function getselectNum (userId) {
  return fetch({
    url: '/wechat/registrationRecord/selectNumByUserId',
    method: 'get',
    params: {
      userId
    }
  })
}

export function getCollectDate (userId,pageNo) {
  return fetch({
    url: '/wechat/registrationCollect/list',
    method: 'get',
    params: {
      userId,
      pageNo
    }
  })
}
export function getParticipationDate (userId,pageNo) {
  return fetch({
    url: '/wechat/registrationRecord/list',
    method: 'get',
    params: {
      userId,
      pageNo
    }
  })
}
export function getOderPayDate (userId,pageNo) {
  return fetch({
    url: '/wechat/registrationOrder/list',
    method: 'get',
    params: {
      userId,
      pageNo
    }
  })
}
export function getVoucherInfoDate (userId,registrationId,pageNo) {
  return fetch({
    url: '/wechat/registrationRecord/list',
    method: 'get',
    params: {
      userId,
      registrationId,
      pageNo
    }
  })
}


